package leetcode;

/**
 * Created by baoyunfeng on 2018/1/31.
 * https://leetcode.com/problems/reverse-integer/description/
 */
public class Reverse_Integer {


    public static void main(String args[]) {
        System.out.println(reverse(-1234));
    }

    public static long reverse(int x) {
        int res = 0;
        while (x != 0) {
            int t = res * 10 + x % 10;
            if (t / 10 != res) return 0;
            res = t;
            x = x / 10;
        }
        return  res;
    }
}
